import euclid

class Bat(object):
    def __init__(self,g,size):
        self.g=g
        if size==0:
            self.img=g.LoadImg('bats/bat_s.png')        
        elif size==1:
            self.img=g.LoadImg('bats/bat_m.png')        
        else:
            self.img=g.LoadImg('bats/bat_x.png')                    
        self.width=self.img.width
        self.height=self.img.height
        self.maxy=64
        self.miny=self.maxy-self.height
        self.pos=euclid.Vector2(self.g.mx,self.maxy-self.height//2)

    def ChkWallCollisions(self):
        #Todo: Left wall
        if self.pos.x-self.width//2<=0:
            self.pos.x=self.width//2
            return
        #Todo: Right wall
        if self.pos.x+self.width//2>=self.g.width:
            self.pos.x=self.g.width-self.width//2
            return

    def Loop(self,mx):
        self.pos.x=mx
        if self.g.state & self.g.PRE: self.ChkWallCollisions()    
        
    def Draw(self):
        self.img.set_position(self.pos.x,self.pos.y)
        self.img.draw()
